/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package meteocal.boundary;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import meteocal.entity.Users;
import meteocal.entityManager.UserManager;
 

 
@Named
@SessionScoped
public class SelectManyView implements Serializable{
     
    private List<String> selectedEmails;
    private List<String> emails;
    
    @Inject
    CalendarBean cb;
    
    @Inject
    UserManager um;
    
     
    @PostConstruct
    public void init() {
        emails = new ArrayList<String>();
        List <Users> user = um.getAllUsers();
        int i = 0;
        for(Users u: user){
            if(!u.equals(um.getLoggedUser())){
            emails.add(u.getEmail());
            i++;
            }
        }
    }
 
    public List<String> getEmails() {
        return emails;
    }

 
    public List<String> getSelectedEmails() {
        return selectedEmails;
    }
 
    /**
     *
     * @param selectedEmails
     */
    public void setSelectedEmails(List<String> selectedEmails) {
        this.selectedEmails = selectedEmails;
        cb.getEvent().setInvited(selectedEmails);
        this.selectedEmails = new ArrayList<>();
    }
}
